package oh.june.calleridentifier.module;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class RedBorderLayout extends LinearLayout{

	public int border = 6;
	
	public RedBorderLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
		super.setBackgroundColor(Color.argb(0, 0, 0, 0));
	}

	public RedBorderLayout(Context context) {
		super(context);
		//super.setBackgroundColor(Color.argb(100, 0, 0, 0));
		super.setBackgroundColor(Color.TRANSPARENT);
	}
	
	@SuppressLint("DrawAllocation")
	@Override
	protected void onDraw(Canvas canvas) {
		int w = this.getWidth();
		int h = this.getHeight();
		
		Paint paint = new Paint();
		paint.setStyle(Style.STROKE);
		paint.setStrokeWidth(border);
		paint.setColor(Color.argb(200, 193, 77, 80));
		paint.setAntiAlias(true);
		Rect boundRect = new Rect(0,0,w,h);
		canvas.drawRoundRect(new RectF(boundRect), 12.0f, 12.0f, paint);
		
		paint.setStyle(Style.FILL);
		paint.setColor(Color.argb(150, 0, 0, 0));
		Rect innerRect = new Rect(border, border, w - border, h - border);
		canvas.drawRoundRect(new RectF(innerRect), 12.0f, 12.0f, paint);
		
		super.onDraw(canvas);
	}

}
